package day06;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

/**
 * @author zouran
 * createDate：2024/6/29  13:26
 */
public class UdpClient {
    public static void main(String[] args) throws IOException {
        while (true) {
            DatagramSocket client = new DatagramSocket();
            Scanner scanner = new Scanner(System.in);
            String message;
            System.out.println("请发送信息給服务端(localhost)");
            System.out.print("请输入信息:");
            message = scanner.nextLine();
            byte[] bytes = message.getBytes();
            DatagramPacket packet = new DatagramPacket(bytes, 0, bytes.length, InetAddress.getByName("127.0.0.1"), 10000);
            client.send(packet);
            client.close();
        }
    }
}
